function CommonBase() {
}

module.exports = CommonBase;

CommonBase.ReturnFunction = function (callback, errMessage) {
    return function (err, result) {
        if(err)
        {
            if(errMessage != undefined && errMessage != null && typeof errMessage == "string")
            {
                console.log(errMessage);
            }
            return callback(err);
        }
        result = JSON.parse(JSON.stringify(result));
        return callback(null, result);
    };
};

CommonBase.CheckParam = function(callback, param, type){
    if(param == null || param == 'undefined' ||typeof param == 'undefined')
    {
        callback({
            err : "param error",
            message : "param is null"
        });
        return false;
    }
    if(type != null && typeof param != type)
    {
        callback({
            err : "param error",
            message : "type of param is wrong"
        });
        return false;
    }
    return true;
}